# @文件:  D:/PycharmProjects/pythonProject/01_Module_C/auto_test_01/page\page_login.py
# @作者:    邱剑萍
# @创建时间:    2025/4/6 19:20

from selenium.webdriver.common.by import By
from time import sleep

from base.base import Base


# 用户名
user_name = By.CSS_SELECTOR, 'input[type="text"]'

# 密码
pwd = By.CSS_SELECTOR, 'input[type="password"]'

# 登录按钮

login_btn = By.CSS_SELECTOR,'button'


success_msg  = By.CSS_SELECTOR,'.el-message__content'

# 登录错误信息
error_msg = By.CSS_SELECTOR,'.el-message__content'


class PageLogin(Base):
    # 输入用户名
    def page_username(self,value):
        self.base_input(user_name,value)

    # 输入密码
    def page_psw(self,value):
        self.base_input(pwd,value)

    # 点击登录按钮
    def page_click_login_btn(self):
        self.base_clik(login_btn)

    # 获取成功信息
    def page_get_success_msg(self):
        self.base_get_text(success_msg)

    # 获取失败信息
    def page_get_error_msg(self):
        self.base_get_text(error_msg)

    # 组合业务（登录）
    def page_log_in(self,username,password):
        self.page_username(username)
        self.page_psw(password)
        sleep(2)
        self.page_click_login_btn()